package com.hzlh.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hzlh.common.util.BaseConstants;
import com.hzlh.core.utils.StringUtils;
import com.hzlh.domain.po.UserOperLogPo;
import com.hzlh.mapper.LogMapper;

@Service
public class LogService {

	@Autowired
	private LogMapper logMapper;
	
	public Map<String,Object> page(String userName, int pageIndex,int pageSize){
		Map<String, Object> remap = new HashMap<String,Object>();
		Map<String,Object> map = new HashMap<String,Object>();
		if(StringUtils.isNotBlank(userName)){
			map.put("userName", userName);
		}
		map.put("start", pageIndex);
		map.put("end", pageSize);
		int count = logMapper.getLogCount(map);
		List<UserOperLogPo> list = null;
		if(count > 0){
			list = logMapper.getLogPage(map);
		}
		remap.put(BaseConstants.MCPP_HC_TOTAL_RECORDS, count);
		remap.put(BaseConstants.MCPP_HC_PAGE_DATA, list);
		return remap;
	}
	
	public int save(UserOperLogPo logPo) {
		return logMapper.insertLog(logPo);
	}
	
	

}
